<?php

namespace App\Repositories\Bonus;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\Bonus\BonusTypeRepository;
use App\Models\Bonus\BonusType;
use App\Validators\Bonus\BonusTypeValidator;

/**
 * Class BonusTypeRepositoryEloquent
 * @package namespace App\Repositories\Bonus;
 */
class BonusTypeRepositoryEloquent extends BaseRepository implements BonusTypeRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return BonusType::class;
    }

    /**
    * Specify Validator class name
    *
    * @return mixed
    */
    public function validator()
    {

        return BonusTypeValidator::class;
    }


    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }

    public function getBonusById($bonusId)
    {
        return B::table('user_bonus as ub')
            ->leftJoin('bonus_type as bt','ub.bonus_type_id','=','bt.type_id')
            ->where('ub.bonus_id','=',$bonusId)
            ->select()
            ->get()
            ->toArray();
    }
}
